<template>


  <el-main><!--搜索框-->
    <el-form size="mini" :model="roleForm" label-width="80px">
      <el-row>
        <el-col :span="5">
          <el-form-item label="名称">
            <el-input v-model="roleForm.roleName" placeholder="请输入角色名称"></el-input>
          </el-form-item>
        </el-col>
        <el-button class="btn-left" type="primary" size="mini" icon="el-icon-search">查询</el-button>
        <el-button type="primary" size="mini" icon="el-icon-plus">查询</el-button>
      </el-row>


    </el-form>
    <!--数据表格
      :data 表格数据绑定
      height：表格高度，只要在el-table元素中定义了height属性
             ，即可实现固定表头的表格，而不需要额外的代码。
      border：表格边框
      prop：自动属性需要跟表格数据对应
    -->
    <el-table
        size="mini"
        :data="tableData"
        border
        :height="tableHeight"
        style="width: 100%">
      <el-table-column
          label="日期"
          prop="date"
          >
      </el-table-column>
      <el-table-column
          label="姓名"
          prop="name"
          >
      </el-table-column>
      <el-table-column
          label="地址"
          prop="address">
      </el-table-column>
    </el-table>
    <!--分页组件
    size-change : pageSize改变时候调用
    current—change : 页数改变时候调用
    current-page :当前页
    page-size :页容量
    total: 总条数
    -->
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage1"
        :page-size="100"
        layout="total, prev, pager, next"
        :total="tableData.length">
    </el-pagination>
  </el-main>
</template>

<script>
export default {
  name: "RoleList",
  data() {
    return {

      //搜索框数据绑定
      roleForm: {
        roleName: ''
      },
      //表格高度
      tableHeight:window.innerHeight,
      //表格数据
      tableData: [{
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-08',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-06',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-07',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }]
    }
  },
  methods:{
    //pageSize改变时候调用
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    //页数改变时候调用
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    }
  },
  mounted() {
    //后面的50：根据需要要求空出的高度，自行调整
    this.$nextTick(()=>{
      this.tableHeight=window.innerHeight-550
    });
  }
}
</script>

<style scoped>
.btn-left {
  margin-left: 30px;
}

.el-main {
  padding-top: 5px !important;
}
</style>